package wikisearch.datastructures;

import java.util.*;
/**
 * This is the wrapper for HashMap<String, Vector<Integer>>
 * @author hcho33
 *
 */
public class ParserMap extends HashMap<String, PairVector> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public PairVector get(String key) {

		return super.get(key);
	}
	
	public PairVector put(String key, Integer idx) {
		
		return this.put(key, idx.intValue());
	}
	
	public PairVector put(String key, int idx) {
		
		return this.put(key, idx, idx);
	}
	
	public PairVector put(String key, Pair<Integer, Integer> idx) {
		
		return this.put(key, idx.first, idx.second);
	}
	
	public PairVector put(String key, int fidx, int sidx) {
		
		if (!containsKey(key)) {
			PairVector v = new PairVector();
			v.add(new Pair<Integer, Integer>(fidx, sidx));
			return put(key, v);
		}else {
			
			PairVector curr = super.get(key);
			curr.add(new Pair<Integer,Integer>(fidx, sidx));
			return curr;
		}
	}
	
	public int vectorLen(String key) {
		
		return (super.get(key) == null ? 
					0 : super.get(key).size());
				
	}
	
	public void print() {
		Set<String> entries = this.keySet();
		for (String e : entries) {
			System.out.println("" + e + ":" + this.get(e));
		}
	}
}
